<?php
/**
 * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved.
 * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
 *
 * Glory to Ukraine! Glory to the heroes!
 */
?>
<?php
/**
 * Blog post list item template
 *
 * @var $block \Magefan\Blog\Block\Post\AbstractPost
 */
?>
<?php
    $descLength = '1000';
    $_post = $this->getPost();
    $_postUrl = $_post->getPostUrl();
    $_postName = $block->escapeHtml($_post->getTitle(), null, true);
?>
<li class="post-holder post-holder-<?php echo $_post->getId() ?>">
    <div class="post-header">

        <div class="post-title-holder clearfix">
            <h2 class="post-title">
                <a class="post-item-link"
                   href="<?php echo $_postUrl ?>">
                    <?php echo $_postName; ?>
                </a>
            </h2>

            <div class="addthis_toolbox addthis_default_style"
                addthis:url="<?php echo $_postUrl ?>"
                addthis:title="<?php echo $_postName; ?>"
                <?php if ($firstImage = $_post->getFirstImage()) { ?>
                addthis:media="<?php echo $firstImage ?>"
                <?php } ?>>
                <a class="addthis_button_facebook"></a>
                <a class="addthis_button_twitter"></a>
                <a class="addthis_button_email"></a>
                <a class="addthis_button_compact"></a>
            </div>
        </div>

        <?php echo $this->getInfoHtml() ?>
    </div>

    <div class="post-content">
        <div class="post-description clearfix">
            <?php if ($featuredImage = $_post->getFeaturedImage()) { ?>
            <div class="post-ftimg-hld">
                <a href="<?php echo $_postUrl ?>" title="<?php echo $_postName ?>">
                    <img src="<?php echo $featuredImage ?>" alt="<?php echo $_postName ?>" />
                </a>
            </div>
            <?php } ?>
            <div class="post-text-hld clearfix">
                <?php //echo $block->getShorContent() 
                    $desc = $_post->getContent();
                    if(strlen($desc)> $descLength ) { 
                        $strCutDesc = substr($desc, 0, $descLength);
                        $desc = substr($strCutDesc, 0, strrpos($strCutDesc, ' ')).'&hellip;';
                    }
                    $desc = $this->stripTags($desc,null,true);
                    echo $desc;

                ?>
            </div>
            <a class="post-read-more" href="<?php echo $_postUrl ?>" title="<?php echo $_postName ?>"
               >
               <?php echo __('Read more &#187;') ?>
            </a>
        </div>
    </div>
    <div class="post-footer">

    </div>
</li>